<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Evan
 * Date: 12-10-3
 * Time: 下午11:09
 * To change this template use File | Settings | File Templates.
 */
class Model_Sso_LoginAccoutsDao extends Zend_Db_Table_Abstract
{
    protected $_primary = 'id';
    protected $_name = 'sso_login_accounts';

    public function verify($loginName, $loginPwd)
    {
        $select = $this->select();
        $select->setIntegrityCheck(false);

//        $select->from($this, array('count(*) AS c'));

        $select->from(array('ac' => 'sso_login_accounts'), array('id',
                                                                 'login_name'))
            ->join(array('ep' => 'orz_employees'),
                   'ac.orz_employee_id = ep.id',
                   array('employee_name'))
            ->where('ac.login_name = :loginName
                    and ac.login_pwd = :loginPwd
                    and ac.is_deleted = :isDeleted
                    and ac.is_available = :is_available');
        $select->bind(array(':loginName' => $loginName,
                            ':loginPwd' => $loginPwd,
                            ':isDeleted' => 'N',
                            ':is_available' => 'Y'));

//        $select->from('sso_login_accounts', '*')
//            ->join('orz_employees',
//                   'sso_login_accounts.orz_employee_id = orz_employees.id',
//                   '*');

        $row = $this->fetchRow($select);

        return $row;
    }
}
